import 'package:flutter_admin/utils/utils.dart';

class ProductUserhourcost {
  String? id;
  String? workshopId;
  String? factoryId;
  String? stationId;
  String? productdate;

  String? reportyield;
  String? hourcost;
  String? mouldcount;
  String? mouldcost;
  String? remark;
  String? createUid;
  String? createName;
  String? createDate;
  String? writeUid;
  String? writeDate;
  String? workshopName;
  String? factoryName;
  String? stationName;

  ProductUserhourcost({
    this.id,
    this.workshopId,
    this.factoryId,
    this.stationId,
    this.productdate,
    this.reportyield,
    this.hourcost,
    this.mouldcount,
    this.mouldcost,
    this.remark,
    this.createUid,
    this.createName,
    this.createDate,
    this.writeUid,
    this.writeDate,
    this.factoryName,
    this.stationName,
    this.workshopName,
  });

  ProductUserhourcost copyWith({
    String? id,
    String? workshopId,
    String? factoryId,
    String? stationId,
    String? productdate,
    String? teamId,
    String? shiftId,
    String? reportyield,
    String? hourcost,
    String? mouldcount,
    String? mouldcost,
    String? remark,
    String? createUid,
    String? createDate,
    String? writeUid,
    String? writeDate,
  }) {
    return new ProductUserhourcost(
      id: id ?? this.id,
      workshopId: workshopId ?? this.workshopId,
      factoryId: factoryId ?? this.factoryId,
      stationId: stationId ?? this.stationId,
      productdate: productdate ?? this.productdate,
      reportyield: reportyield ?? this.reportyield,
      hourcost: hourcost ?? this.hourcost,
      mouldcount: mouldcount ?? this.mouldcount,
      mouldcost: mouldcost ?? this.mouldcost,
      remark: remark ?? this.remark,
      createUid: createUid ?? this.createUid,
      createDate: createDate ?? this.createDate,
      writeUid: writeUid ?? this.writeUid,
      writeDate: writeDate ?? this.writeDate,
    );
  }

  @override
  String toString() {
    return '''ProductUserhourcost{
      id: $id,
      workshopId: $workshopId,
      workshopName: $workshopName,
      factoryId: $factoryId,
      factoryName: $factoryName,
      stationId: $stationId,
      stationName: $stationName,
      productdate: productdate,
     
      reportyield: reportyield,
      hourcost: hourcost,
      mouldcount: mouldcount,
      mouldcost: mouldcost,
      remark: remark,
      createUid: createUid,
      createName: $createName,
      createDate: createDate,
      writeUid: writeUid,
      writeDate: writeDate,
    }''';
  }

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      (other is ProductUserhourcost &&
          runtimeType == other.runtimeType &&
          id == other.id &&
          workshopId == other.workshopId &&
          factoryId == other.factoryId &&
          stationId == other.stationId &&
          productdate == other.productdate &&
          reportyield == other.reportyield &&
          hourcost == other.hourcost &&
          mouldcount == other.mouldcount &&
          mouldcost == other.mouldcost &&
          remark == other.remark &&
          createUid == other.createUid &&
          createDate == other.createDate &&
          writeUid == other.writeUid &&
          writeDate == other.writeDate);

  factory ProductUserhourcost.fromMap(Map<String, dynamic> map) {
    return new ProductUserhourcost(
      id: map['id'] != false ? map['id'].toString() as String? : "",
      workshopId: map['workshop_id'] != false
          ? map['workshop_id'][0].toString() as String?
          : "",
      workshopName: map['workshop_id'] != false
          ? map['workshop_id'][1].toString() as String?
          : "",
      factoryId: map['factory_id'] != false
          ? map['factory_id'][0].toString() as String?
          : "",
      factoryName: map['factory_id'] != false
          ? map['factory_id'][1].toString() as String?
          : "",
      stationId: map['station_id'] != false
          ? map['station_id'][0].toString() as String?
          : "",
      stationName: map['station_id'] != false
          ? map['station_id'][1].toString() as String?
          : "",
      productdate: map['productdate'] != false
          ? map['productdate'].toString() as String?
          : "",
      reportyield: map['reportyield'] != false
          ? map['reportyield'].toString() as String?
          : "",
      hourcost:
          map['hourcost'] != false ? map['hourcost'].toString() as String? : "",
      mouldcount: map['mouldcount'] != false
          ? map['mouldcount'].toString() as String?
          : "",
      mouldcost: map['mouldcost'] != false
          ? map['mouldcost'].toString() as String?
          : "",
      remark: map['remark'] != false ? map['remark'].toString() as String? : "",
      createUid: map['create_uid'] != false
          ? map['create_uid'][0].toString() as String?
          : "",
      createName: map['create_uid'] != false
          ? map['create_uid'][1].toString() as String?
          : "",
      createDate: map['create_date'] != false
          ?Utils.timeUTC( map['create_date'].toString()) as String?
          : "",
      writeUid: map['write_uid'] != false
          ? map['write_uid'][1].toString() as String?
          : "",
      writeDate: map['write_date'] != false
          ? map['write_date'].toString() as String?
          : "",
    );
  }

  Map<String, dynamic> toMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'workshopId': this.workshopId,
      'workshopName': this.workshopName,
      'factoryId': this.factoryId,
      'factoryName': this.factoryName,
      'stationId': this.stationId,
      'stationName': this.stationName,
      'productdate': this.productdate,
      'reportyield': this.reportyield,
      'hourcost': this.hourcost,
      'mouldcount': this.mouldcount,
      'mouldcost': this.mouldcost,
      'remark': this.remark,
      'createUid': this.createUid,
      'createName': this.createName,
      'createDate': this.createDate,
      'writeUid': this.writeUid,
      'writeDate': this.writeDate,
    } as Map<String, dynamic>;
  }

  List toDomainList() {
    List list = [
      if (this.workshopId != null && this.workshopId != '')
        ['workshop_id', '=', this.workshopId],
      if (this.factoryId != null && this.factoryId != '')
        ['factory_id', '=', this.factoryId],
      if (this.stationId != null && this.stationId != '')
        ['station_id', '=', this.stationId],
    ] as List;
    if (list.length == 0) {
      list.add(['id', '!=', null]);
    }
    // ignore: unnecessary_cast
    return list;
  }

  Map<String, dynamic> toOdooMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'workshop_id': int.parse(this.workshopId!),
      'factory_id': int.parse(this.factoryId!),
      'station_id': int.parse(this.stationId!),
      'productdate': this.productdate,
      'reportyield': int.parse(this.reportyield!),
      'hourcost': int.parse(this.hourcost!),
      'mouldcount': int.parse(this.mouldcount!),
      'mouldcost': int.parse(this.mouldcost!),
      'remark': this.remark,
    } as Map<String, dynamic>;
  }

  // List savalist() {
  //   List list = [
  //     ['workshop_id', '=', int.parse(this.workshopId!)],
  //     ['factory_id', '=', int.parse(this.factoryId!)],
  //     ['station_id', '=', int.parse(this.stationId!)],
  //     ['productdate', '=', this.productdate],
  //     ['reportyield', '=', int.parse(this.reportyield!)],
  //     ['hourcost', '=', int.parse(this.hourcost!)],
  //     ['mouldcount', '=', int.parse(this.mouldcount!)],
  //     ['mouldcost', '=', int.parse(this.mouldcost!)],
  //     ['remark', '=', this.remark]
  //   ] as List;
  //   if (list.length == 0) {
  //     list.add(['id', '!=', null]);
  //   }
  //   // ignore: unnecessary_cast
  //   return list;
  // }

//</editor-fold>

}
